home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / frasr182.zip / PROMPTS2.C < prev    next >
C/C++ Source or Header  |  1993-08-18  |  51KB  |  1,795 lines

  1. /*
  2.     Various routines that prompt for things.
  3.     This module is linked as an overlay, use ENTER_OVLY and EXIT_OVLY.
  4. */
  5.  
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <ctype.h>
  10. #ifndef XFRACT
  11. #include <dos.h>
  12. #elif !defined(__386BSD__)
  13. #include <sys/types.h>
  14. #include <sys/stat.h>
  15. #include <sys/dir.h>
  16. #endif
  17. #ifdef __TURBOC__
  18. #include <alloc.h>
  19. #elif !defined(__386BSD__)
  20. #include <malloc.h>
  21. #endif
  22.  
  23. #ifdef __hpux
  24. #include <sys/param.h>
  25. #define getwd(a) getcwd(a,MAXPATHLEN)
  26. #endif
  27.  
  28. #include "fractint.h"
  29. #include "fractype.h"
  30. #include "helpdefs.h"
  31. #include "prototyp.h"
  32.  
  33. /* Routines defined in prompts1.c */
  34.  
  35. extern    int prompt_checkkey(int curkey);
  36. extern    long get_file_entry(int,char *,char *,char *,char *);
  37.  
  38. /* Routines used in prompts1.c */
  39.  
  40.     int get_corners(void);
  41.     int edit_ifs_params(void );
  42.     int lccompare(VOIDCONSTPTR, VOIDCONSTPTR); /* Needed in prompts1.c PAV */
  43.  
  44. /* Routines in this module    */
  45.  
  46. static    int findfirst(char *path);
  47. static  int check_f6_key(int curkey,int choice);
  48. static    int findnext(void );
  49.     int splitpath(char *template,char *drive,char *dir,char *fname,char *ext);
  50.         int makepath(char *template,char *drive,char *dir,char *fname,char *ext);
  51. static    void fix_dirname(char *dirname);
  52. static    int expand_dirname(char *dirname,char *drive);
  53. static    int filename_speedstr(int, int, int, char *, int);
  54. static    int isadirectory(char *s);
  55. static  int check_f6_key(int curkey,int choice);
  56.  
  57. extern int dotmode;
  58. extern int orbit_delay;
  59. extern char diskfilename[];
  60.  
  61. extern char *fract_dir1, *fract_dir2;
  62.  
  63. #ifndef XFRACT
  64. extern int strncasecmp(char *s,char *t,int ct);
  65. #endif
  66.  
  67. extern char temp1[256];   /* temporary strings          */
  68.  
  69. extern    double    xxmin,xxmax;    /* initial corner values    */
  70. extern    double    yymin,yymax;    /* initial corner values    */
  71. extern    BYTE usemag;
  72.  
  73. extern    int AntiAliasing;
  74. extern double zzmin, zzmax, ttmin, ttmax;
  75. extern int Transparent3D;
  76.  
  77. extern    double    xx3rd,yy3rd;    /* initial corner values    */
  78. extern    int    invert;     /* non-zero if inversion active */
  79. extern    double    inversion[3];    /* radius, xcenter, ycenter */
  80. extern    int    pot16bit;
  81. extern    int    disk16bit;
  82. extern    double    potparam[3];    /* three potential parameters*/
  83. extern    int    fractype;    /* if == 0, use Mandelbrot  */
  84. extern    char    usr_floatflag;    /* floating-point fractals? */
  85. extern    int    maxit;        /* try this many iterations */
  86. extern    int    inside;     /* inside color */
  87. extern    int    fillcolor;     /* fill color */
  88. extern    int    outside;    /* outside color */
  89. extern    int    finattract;    /* finite attractor switch */
  90. extern    char    savename[80];    /* save files using this name */
  91. extern    int    decomp[];    /* decomposition parameters */
  92. extern    int    usr_distest;    /* distance estimator option */
  93. extern    int    distestwidth;
  94. extern    char    usr_stdcalcmode; /* '1', '2', 'g', 'b' */
  95. extern    char    overwrite;     /* overwrite= flag */
  96. extern    int    soundflag;    /* sound option */
  97. extern    int    LogFlag;    /* non-zero if logarithmic palettes */
  98. extern    int    usr_biomorph;    /* Biomorph flag */
  99. #if 0
  100. //extern    long    xmin, xmax, ymin, ymax; /* screen corner values */
  101. #endif
  102. extern    int    xdots, ydots;    /* coordinates of dots on the screen  */
  103. extern    int    colors;     /* maximum colors available */
  104. extern    int    row, col;
  105. extern    int    viewwindow;
  106. extern    float    viewreduction;
  107. extern    int    viewcrop;
  108. extern    float    finalaspectratio;
  109. extern    int    viewxdots,viewydots;
  110. extern    int    textcbase;
  111. extern    int    textrow,textcol;
  112. extern    int    resave_flag;    /* resaving after a timed save */
  113. extern    int    started_resaves;
  114. extern    char    boxy[];
  115. extern    int    rotate_lo,rotate_hi;
  116. extern    int    rangeslen;
  117. extern float  screenaspect;
  118.  
  119. extern  int  cmdarg(char *,int);
  120.  
  121. extern char CommandFile[];
  122. extern char CommandName[];
  123. extern float far *ifs_defn;
  124. extern int ifs_type;
  125. extern int ifs_changed;
  126. extern int initbatch;        /* 1 if batch run (no kbd)  */
  127.  
  128. /* speed key state values */
  129. #define MATCHING     0    /* string matches list - speed key mode */
  130. #define TEMPLATE    -2    /* wild cards present - buiding template */
  131. #define SEARCHPATH    -3    /* no match - building path search name */
  132.  
  133. #define   FILEATTR     0x37       /* File attributes; select all but volume labels */
  134. #define   HIDDEN     2
  135. #define   SYSTEM     4
  136. #define   SUBDIR     16
  137. #define   MAXNUMFILES     300
  138.  
  139. struct                   /* Allocate DTA and define structure */
  140. {
  141.      char path[21];            /* DOS path and filespec */
  142.      char attribute;            /* File attributes wanted */
  143.      int  ftime;            /* File creation time */
  144.      int  fdate;            /* File creation date */
  145.      long size;             /* File size in bytes */
  146.      char filename[13];         /* Filename and extension */
  147. } DTA;                   /* Disk Transfer Area */
  148.  
  149. #define GETFORMULA 0
  150. #define GETLSYS    1
  151. #define GETIFS       2
  152. #define GETPARM    3
  153.  
  154. /* --------------------------------------------------------------------- */
  155. extern char s_iter[];
  156. extern char s_real[];
  157. extern char s_mult[];
  158. extern char s_sum[];
  159. extern char s_imag[];
  160. extern char s_zmag[];
  161. extern char s_bof60[];
  162. extern char s_bof61[];
  163. extern char s_maxiter[];
  164. extern char s_epscross[];
  165. extern char s_startrail[];
  166. extern char s_normal[];
  167. extern char s_period[];
  168.  
  169. char commandmask[13] = {"*.par"};
  170.  
  171. void prompts2_overlay() { }    /* for restore_active_ovly */
  172.  
  173. #if 0
  174. /* --------------------------------------------------------------------- */
  175.  
  176. extern int promptfkeys;
  177.  
  178. int edit_ifs_params()    /* prompt for IFS params */
  179. {
  180.    int totcols;
  181.    int i, j, k, numlines, ret;
  182.    FILE *tempfile;
  183.    char msg[81];
  184.    char filename[81];
  185.    float ftemp;
  186.    int oldhelpmode;
  187.    int low, hi;
  188.  
  189.    if (!ifs_defn && !ifsload())
  190.       return(-1);
  191.  
  192.    totcols = (ifs_type == 0) ? IFSPARM : IFS3DPARM;
  193.    ret = 0;
  194.    oldhelpmode = helpmode;
  195.    helpmode = HT_IFS;
  196.  
  197.    low = 0;
  198.  
  199.    for ( ;; ) {
  200. static char far ifshdg2[]={"2D IFS Parameters"};
  201. static char far ifshdg3[]={"3D IFS Parameters"};
  202. static char far ifsparmmsg1[]={"#    a     b     c     d     e     f"};
  203. static char far ifsparmmsg2[]={"     g     h     i     j     k     l"};
  204. static char far ifsprompt[]={"\
  205. Enter the number of the line you want to edit,\n\
  206. S to save, F6 for corners, or ENTER to end ==>"};
  207.       int leftcol,promptrow,promptcol;
  208. #define IFS_NUM 12
  209.  
  210.       for (numlines = 0; numlines < NUMIFS; numlines++) /* find the first zero entry */
  211.      if (ifs_defn[(numlines * totcols) + totcols - 1] <= 0.0001) break;
  212.  
  213.       helptitle();
  214.       setattr(1,0,C_PROMPT_BKGRD,24*80); /* init rest of screen to background */
  215.       putstringcenter(2,0,80,C_GENERAL_HI,(ifs_type == 0) ? ifshdg2 : ifshdg3);
  216.       leftcol = (ifs_type == 0) ? 15 : 0;
  217.       putstring(4,leftcol+1,C_GENERAL_HI,ifsparmmsg1);
  218.       if (ifs_type != 0)
  219.      putstring(-1,-1,C_GENERAL_HI,ifsparmmsg2);
  220.       putstring(-1,-1,C_GENERAL_HI,"   prob \n\n");
  221.  
  222.       hi = low+IFS_NUM;
  223.       if (hi>numlines) hi = numlines;
  224.       for (i = low; i < hi; i++) {
  225.      sprintf(msg,"%2d", i+1);
  226.      putstring(5+i-low,leftcol,C_GENERAL_HI,msg);
  227.      for (j = 0; j < totcols; j++) {
  228.         sprintf(msg,"%6.2f",ifs_defn[(i*totcols)+j]);
  229.         putstring(-1,-1,C_GENERAL_MED,msg);
  230.         }
  231.      }
  232.       if (hi<numlines) {
  233.      putstring(5+IFS_NUM,leftcol,C_GENERAL_HI,"(more)");
  234.       }
  235.  
  236.       textcbase = 14;
  237.       putstring(5+i-low+1,0,C_GENERAL_HI,ifsprompt);
  238.       promptrow = textrow;
  239.       promptcol = textcol + textcbase + 1;
  240.       temp1[0] = textcbase = 0;
  241.       promptfkeys = 1<<6;
  242.       i = input_field(0,C_GENERAL_INPUT,temp1,2,promptrow,promptcol,
  243.           prompt_checkkey);
  244.       if (i<0) {
  245.       break;
  246.       } else if (i==PAGE_UP) {
  247.       low -= IFS_NUM;
  248.       if (low<0) low=0;
  249.       } else if (i==UP_ARROW) {
  250.       low -= 1;
  251.       if (low<0) low=0;
  252.       } else if (i==DOWN_ARROW) {
  253.       low += 1;
  254.       if (low+IFS_NUM>numlines) low=numlines-IFS_NUM;
  255.       if (low<0) low=0;
  256.       } else if (i==PAGE_DOWN) {
  257.       low += IFS_NUM;
  258.       if (low+IFS_NUM>numlines) low=numlines-IFS_NUM;
  259.       if (low<0) low=0;
  260.       } else if (i==F6) {
  261.       if (get_corners()) {
  262.           ret = 1;
  263.       }
  264.       } else if (i==0) {
  265.       if (temp1[0]==0) break;
  266.       } else {
  267.       continue;
  268.       }
  269.  
  270.       putstring(promptrow,promptcol,C_GENERAL_HI,temp1);
  271.       if (temp1[